const mysql=require("mysql")

const con=mysql.createConnection({
  host:"localhost",
  user:"root",
  password:"admin",
  port:"3306",
  database:"zigl"
})

//开始连接
con.connect()


let comMysql=function(sql,arr){
  return new Promise((resolve,reject)=>{
    con.query(sql,arr,(err,data)=>{
      if(err){
        reject(err)
      }else{
        
        resolve(data)
      }
    })
  })
}
console.log("数据库连接成功");

module.exports={
  comMysql,
  secretOrKey:"secret"
}

